#include <iostream>
using namespace std;
class Rational {
public:
	void hua();
	void dai();
		long long numerator1;
	long long denominator1;
	long long zheng;
	Rational(long long zheng=0,long long numerator1 = 4, long long denominator1 = 6)
	{
		this->zheng = zheng;
		this->numerator1 = numerator1;
		if (denominator1 < 0)
			return;
		else
			this->denominator1 = denominator1;
	}
	Rational(const Rational& c)
	{
		zheng = c.zheng;
		numerator1 = c.numerator1;
		denominator1 = c.denominator1;
	}
	friend Rational operator*(Rational a, Rational b);
	friend Rational operator+(Rational a, long long zt);
	friend Rational operator/(Rational a, Rational b);
	friend Rational operator+(long long zt, Rational a);
	friend Rational operator-(Rational a);
	friend Rational operator++(Rational a, int );
	friend Rational operator+ (Rational a, Rational b);
	friend Rational operator- (Rational a, Rational b);
	friend ostream& operator<<(ostream& os, Rational a);
     operator double();
  void operator= (Rational a);
};
Rational operator*(Rational a, Rational b)
{
	Rational c;
	c.numerator1 = a.numerator1 * b.numerator1;
	c.denominator1 = a.denominator1 * b.denominator1;
	c.hua();
	c.dai();
	return c;
}

Rational operator/(Rational a, Rational b)
{
	Rational c;
	c.numerator1 = a.numerator1 / b.numerator1;
	c.denominator1 = a.denominator1 / b.denominator1;
	c.hua();
	c.dai();
	return c;
}

Rational operator+(Rational a,  int zt) {
	a.zheng = a.zheng + zt;
	a.hua();
	a.dai();
	return a;
}
Rational operator+( int zt, Rational a)
{
	a.zheng = a.zheng + zt;
	a.hua();
	a.dai();
	return a;
}
Rational operator-(Rational a)
{
	a.numerator1 = -a.numerator1;
	a.hua();
	a.dai();
	return a;
}
Rational operator++(Rational a,int)
{
	a.zheng=a.zheng+1;
	a.hua();
	a.dai();
	return a;
}
Rational operator+ (Rational a, Rational b)
{
	
	if (a.denominator1 > 1000000000000000)
		a.denominator1 = a.denominator1 / 10000000000;
	if (b.denominator1 > 1000000000000000)
		b.denominator1 = b.denominator1 / 10000000000;
	if (a.numerator1 > 1000000000000000)
		a.numerator1 = a.numerator1 / 10000000000;
	if (b.numerator1 > 1000000000000000)
		b.numerator1 = b.numerator1 / 10000000000;
	Rational c;
	c.zheng = a.zheng + b.zheng;
	c.denominator1 = a.denominator1 * b.denominator1;
	c.numerator1 = b.denominator1 * a.numerator1 + a.denominator1 * b.numerator1;
	c.hua();
	c.dai();
	return c;
}
Rational operator- (Rational a, Rational b)
{
	Rational c;
	c.denominator1 = a.denominator1 * b.denominator1;
	c.numerator1 = b.denominator1 * a.numerator1 - a.denominator1 * b.numerator1;
	c.hua();
	c.dai();
	return c;
}
ostream& operator<<(ostream& os,Rational a)
{
	if(a.zheng==0)
	cout << a.numerator1 << "/" << a.denominator1 << endl;
	else
		cout <<a.zheng<<"又"<< a.numerator1 << "/" << a.denominator1 << endl;
	return os;
}
 Rational:: operator double()
{
	double zt;
	zt = (this->numerator1 / this->denominator1)+this->zheng;
	return zt;
}
 void Rational::operator=(Rational a)
 {
	 this->zheng = a.zheng;
	 this->numerator1 = a.numerator1;
	 this->denominator1 = a.denominator1;
 }
 void Rational::hua()
 { 
	 long long x = this->numerator1;
	 long long y = this->denominator1;
	 long long z = this->denominator1;
	 while (x % y!= 0)
	 {
		 z =x % y;
		 x= y;
		 y = z;
	 }
	  this->numerator1 = this->numerator1 / z;
	  this->denominator1 = this->denominator1 / z;
 }
 void Rational::dai()
 {
	 if (abs(this->numerator1) > this->denominator1)
	 {
		 this->zheng = this->zheng + (abs(this->numerator1) / abs(this->denominator1));
		 this->numerator1 = this->numerator1 % this->denominator1;
	 }
	
 }
int main() 
{
	Rational rat0;
	cout << rat0 << endl;
	Rational rat1 = -rat0;
	cout << rat1 << endl;
	Rational rat2 = rat1 + 34;
	cout << rat2 << endl;
	Rational rat3;
	rat3 = 12 + rat2;
	rat3++;
	cout << rat3 << endl;
	cout << (double)rat3 << endl;
	Rational result(0,1, 2);
	for (long long i = 3; i <= 50; i++)
	{
		Rational yy(0,i - 1, i);
			result = result + yy;
	}
	
	cout << result;
	return 0;
}